import { fmtTime } from "@/utils"
// 存
export function setStorage(key:string,val:any){
    console.log("setStorage");
    
    const data = {
        time:fmtTime(new Date()),
        data:val
    }
    localStorage.setItem(key,JSON.stringify(data)); 
}

// 取
export function getStorage(key:string){
    const data = localStorage.getItem(key)
    if(!data){
        return null;
    }else{
        return JSON.parse(data).data
    }
}

// 删
export function removeStorage(key:string){
    return localStorage.removeItem(key);
}

// 清空
export function clearStorage(){
    return localStorage.clear();
}